<?php
/***************************************************************************
 *
 *   copyright            : (C) 2006 Erik Forbes
 *
 *   $Id: answersfilter.php,v 1.1 2006/03/03 16:15:24 nathan Exp $
 *
 ***************************************************************************/

/***************************************************************************
 *
 *   This program is free software; you can redistribute it and/or modify
 *   it under the terms of the GNU General Public License as published by
 *   the Free Software Foundation; either version 2 of the License, or
 *   (at your option) any later version.
 *
 ***************************************************************************/

$answersfilter = array(	'TYPE'		=>      'filter',
			'NAME'		=>      'Answers Quicklink Filter',
			'VERSION'	=>      '1.0.0',
			'CREDIT'	=>      'Erik Forbes',
			'FUNC'		=>      'pluginAnswersFilter',
			'HELP'		=>      'pluginAnswersFilterHelp'
		);
$plugins[]	= $answersfilter;

function pluginAnswersFilterHelp($help) {
	global	$answersfilter;

	$help['answers'] = array('answers:[topic]',
				 'Shows a chat-friendly link to the Answers.com topic for [topic]' .
				 pluginCredit($answersfilter)
				);

	return $help;
}

function pluginAnswersFilter($msg) {
	global	$db;
	global	$dbprefix;
	
	// answers:whatever should translate to:
	//    <a target="_blank" href="http://www.answers.com/[topic]">Answers.com: [topic]</a>
	
	if (eregi("answers:", $msg)) {
		$msg	= eregi_replace("answers:([[:alnum:]]+)", "<a href=\" http://www.answers.com/\\1\" target=\"_blank\">Answers.com: \\1</a>", $msg);
		//addToLog("Answers.com Quicklink Filtered message: $msg");
	}
	
	
	return $msg;
}

?>
